//
//  HLEM3U8WorkFlow.h
//  DownloadM3U8Tool_Example
//
//  Created by hle1879 on 2020/8/28.
//  Copyright © 2020 134344. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HLEM3U8DownloadTask.h"
#import "HLEConfig.h"

@class HLEM3U8WorkFlow;
@protocol WorkflowDelegate <NSObject>

@required
- (void)workflowFinish:(HLEM3U8WorkFlow *_Nonnull)workflow;

@end


NS_ASSUME_NONNULL_BEGIN

@interface HLEM3U8WorkFlow : NSObject

@property (nonatomic,strong,readonly)HLEM3U8DownloadTask *task;
@property (nonatomic,weak)id<WorkflowDelegate>delegate;

- (void)initTask:(HLEM3U8DownloadTask*)task success:(nullable void (^)(HLEM3U8DownloadTask *task))success
         failure:(nullable void (^)(HLEM3U8DownloadTask *task,NSError *error))failure;

- (BOOL)initExitTask:(HLEM3U8DownloadTask*)task;

- (void)downloadWithProgress:(void (^)(HLEM3U8DownloadTask *task,NSProgress *progress, NSInteger allSize))progress
                       speed:(void (^)(HLEM3U8DownloadTask *task,NSInteger speed))speed
                     success:(nullable void (^)(HLEM3U8DownloadTask *task))success
                     failure:(nullable void (^)(HLEM3U8DownloadTask *task,NSError *error))failure;

- (void)pause;

- (BOOL)cancel;

-(void)combineMP4WithFilePath:(NSString*)filepath success:(nullable void (^)(HLEM3U8DownloadTask *task))success failure:(nullable void (^)(HLEM3U8DownloadTask *task,NSError *error))failure complete:(nonnull void (^)(void))complete;

///请求下载完成，私有方法
-(void)taskDidComplete:(NSURLSession * _Nullable)session task:(NSURLSessionTask * _Nonnull)task error:(NSError * _Nullable)error;
@end

NS_ASSUME_NONNULL_END
